import type { AxiosRequestConfig } from 'axios' 
import type { LoadingInstance } from 'element-plus/es/components/loading/src/loading'

/** 自定义请求配置 */
export interface RequestConfig extends AxiosRequestConfig {
  hideLoading?: boolean
  ignoreError?: boolean
  loadingInstance?: LoadingInstance
}


/** 后端统一响应结构 */
export interface ApiResponse<T = unknown> {
  code: number
  message: string
  data: T
}

/** 分页响应结构 */
export interface PaginatedResponse<T> {
  list: T[]
  total: number
  page: number
  pageSize: number
}

/** 类型守卫：检查是否为ApiResponse */
export function isApiResponse<T>(data: unknown): data is ApiResponse<T> {
  return typeof data === 'object' &&
         data !== null &&
         'code' in data &&
         'message' in data
}

// 添加分页类型
export interface PaginatedResponse<T> {
  list: T[]
  total: number
  page: number
  pageSize: number
}
